
# project cocos2d-x
set(pfx ${CMAKE_CURRENT_SOURCE_DIR}/quick-cocos2d-x)
include(cocos_files_define.txt)

set(cocos2d_include ${cocos2d_include_p} PARENT_SCOPE)


set(win32_libdir
    ${pfx}/lib/cocos2d-x/cocos2dx/platform/third_party/win32/libraries
    ${pfx}/lib/cocos2d-x/external/libwebsockets/win32/lib
)

set(mac_libdir
    ${pfx}/lib/cocos2d-x/cocos2dx/platform/third_party/mac/libraries
    ${pfx}/lib/cocos2d-x/external/libwebsockets/mac/lib
)

if (WIN32)
    set(cocos2d_libdir_p ${win32_libdir})
else()
    set(cocos2d_libdir_p ${mac_libdir})
endif()

set(cocos2d_libdir ${cocos2d_libdir_p} PARENT_SCOPE)

add_definitions(
    -DCOCOS2D_DEBUG=1
    -DCC_LUA_ENGINE_ENABLED=1
    #-DCC_CURL_ENABLED=1
    -DCC_JPEG_ENABLED=1
    -DCC_TIFF_ENABLED=1
    -DCC_WEBP_ENABLED=1
    -DCC_SQLITE_ENABLED=1
    -DCC_CCSTUDIO_ENABLED=1
    -DCC_CCB_ENABLED=1
    #-DCC_DRAGONBONES_ENABLED=1
    -DCC_FILTERS_ENABLED=1
    -DUNICODE
    -D_UNICODE
    -D_CRT_SECURE_NO_WARNINGS
    -D_SCL_SECURE_NO_WARNINGS
    -DCC_LUA_ENGINE_ENABLED=1
)
if (WIN32)
    set(PLATFORM_SPECIFIC_LIBS
        winmm
        glew32
        ws2_32
        wsock32
        opengl32
        pthreadVCE2
        libcurl_imp
        libiconv
        libjpeg
        libpng
        libtiff
        libzlib
        libwebp
    )
    add_definitions(-DWIN32)
    add_definitions(-D_WINDOWS)
else()
    add_definitions(-DCC_TARGET_OS_MAC)
    add_definitions(-DUSE_FILE32API)

    INCLUDE_DIRECTORIES ( /System/Library/Frameworks )
    FIND_LIBRARY(COCOA_LIBRARY Cocoa)
    FIND_LIBRARY(OPENGL_LIBRARY OpenGL )
    FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox)
    FIND_LIBRARY(OPENAL_LIBRARY OpenAL )
    FIND_LIBRARY(QUARTZCORE_LIBRARY QuartzCore )
    FIND_LIBRARY(APPLICATIONSERVICES_LIBRARY ApplicationServices)
    FIND_LIBRARY(IOKIT_LIBRARY IOKit)
    FIND_LIBRARY(FOUNDATION_LIBRARY Foundation)


    set(PLATFORM_SPECIFIC_LIBS
        ${COCOA_LIBRARY}
        ${OPENGL_LIBRARY}
        ${OPENAL_LIBRARY}
        ${AUDIOTOOLBOX_LIBRARY}
        ${QUARTZCORE_LIBRARY}
        ${APPLICATIONSERVICES_LIBRARY}
        ${IOKIT_LIBRARY}
        ${FOUNDATION_LIBRARY}
        -lwebp
      )
endif()

link_directories(${cocos2d_libdir_p})

include_directories(${cocos2d_include_p})


add_library(cocos2d-x STATIC ${src_files})

set(link_libs ${PLATFORM_SPECIFIC_LIBS} websockets )

if(WIN32)
else()
    list(APPEND link_libs -lz )
endif()

target_link_libraries(cocos2d-x ${link_libs})
